import 'package:flutter/material.dart';
import 'package:flutter_dk_form/flutter_dk_form.dart';

class DkMultipleInputFormField extends DkFormField<String> {
  DkMultipleInputFormField({
    Key key,
    @required String attribute,
    String initialValue = '',
    String title,
    ValueChanged<String> onChanged,
    DkFormFieldValidator<String> validator,
    ValueTransformer valueTransformer,
    String placeholder = '',
    int maxInputLength,
  }) : super(
          attribute: attribute,
          initialValue: initialValue,
          validator: validator,
          valueTransformer: valueTransformer,
          builder: (DkFormFieldState<String> field) {
            final DkFormFieldState state = field;
            void onChangedHandler(String value) {
              if (onChanged != null) {
                onChanged(value);
              }
              field.didChange(value);
            }

            return MultipleInputWidget(
              title: title,
              initialValue: state.value,
              onChanged: onChangedHandler,
              placeholder: placeholder,
              maxLength: maxInputLength,
            );
          },
        );
}
